package com.acmedcare.framework.exchange.center.common;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class MethodUtils {

  public static Method getFirstMethod(String name, Object object) {

    List<Method> methods = Arrays.stream(object.getClass().getMethods())
        .filter(m -> m.getName().equals(name)).collect(
            Collectors.toList());
    if (methods.isEmpty()) {

      return null;
    }

    return methods.get(0);
  }
}
